package com.java8.Stream;

import org.junit.Test;

import java.util.*;
import java.util.stream.Stream;

public class demo02_生成Stream流 {
    @Test
    public void test(){
        //1。Collection体系（直接）
        //直接stream()
        List<String> list = new ArrayList<String>();
        Stream<String> liststream = list.stream();

        Set<String> set = new HashSet<String>();
        Stream<String> setStream = set.stream();

        //2.Map体系
        //先转成Set
        HashMap<String, Integer> map = new HashMap<>();
        //keySet
        Stream<String> mapstream = map.keySet().stream();
        //values
        Stream<Integer> mapstream1 = map.values().stream();
        //entrySet
        Stream<Map.Entry<String, Integer>> stream = map.entrySet().stream();

        //3.数组
        String[] arr = new String[]{"张三丰","张无忌","张翠山","王二麻子","张良","谢广坤"};
        Stream<String> stream1 = Arrays.stream(arr);

        //4.相同数据类型的多个数据
        Stream<String> stream2 = Stream.of("hello", "java", "bushu");
        Stream<Integer> stream3 = Stream.of(1, 2, 3);

    }
}
